﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;

namespace RXY_Mall.Core
{
    public class AppConfig
    {
        #region SMS
        /// <summary>
        /// 阿里大于appKey
        /// </summary>
        private static string smsAppKey;
        /// <summary>
        /// 阿里大于appSecret
        /// </summary>
        private static string smsAppSecret;
        /// <summary>
        /// 短信签名
        /// </summary>                    
        private static string smsFreeSignName;
        /// <summary>
        /// 金贝塔
        /// </summary>
        private static string smsProductName;
        /// <summary>
        /// 阿里大于URL
        /// </summary>
        private static string smsUrl;

        /// <summary>
        /// 阿里大于appKey
        /// </summary>
        public static string SmsAppKey
        {
            get
            {
                if (string.IsNullOrEmpty(smsAppKey))
                    smsAppKey = ConfigurationManager.AppSettings["SmsAppKey"];
                return smsAppKey;
            }
        }

        /// <summary>
        /// 阿里大于appSecret
        /// </summary>
        public static string SmsAppSecret
        {
            get
            {
                if (string.IsNullOrEmpty(smsAppSecret))
                    smsAppSecret = ConfigurationManager.AppSettings["SmsAppSecret"];
                return smsAppSecret;
            }
        }

        /// <summary>
        /// 短信签名
        /// </summary>
        public static string SmsFreeSignName
        {
            get
            {
                if (string.IsNullOrEmpty(smsFreeSignName))
                    smsFreeSignName = ConfigurationManager.AppSettings["SmsFreeSignName"];
                return smsFreeSignName;
            }
        }

        /// <summary>
        /// 金贝塔
        /// </summary>
        public static string SmsProductName
        {
            get
            {
                if (string.IsNullOrEmpty(smsProductName))
                    smsProductName = ConfigurationManager.AppSettings["SmsProductName"];
                return smsProductName;
            }
        }

        /// <summary>
        /// 阿里大于URL
        /// </summary>
        public static string SmsUrl
        {
            get
            {
                if (string.IsNullOrEmpty(smsUrl))
                    smsUrl = ConfigurationManager.AppSettings["SmsUrl"];
                return smsUrl;
            }
        }
        #endregion


        #region SMS
        /// <summary>
        /// 阿里大于appKey
        /// </summary>
        private static string KECsmsAppKey;
        /// <summary>
        /// 阿里大于appSecret
        /// </summary>
        private static string KECsmsAppSecret;
        /// <summary>
        /// 短信签名
        /// </summary>                    
        private static string KECsmsFreeSignName;
        /// <summary>
        /// 金贝塔
        /// </summary>
        private static string KECsmsProductName;
        /// <summary>
        /// 阿里大于URL
        /// </summary>
        private static string KECsmsUrl;

        /// <summary>
        /// KEC阿里大于appKey
        /// </summary>
        public static string KECSmsAppKey
        {
            get
            {
                if (string.IsNullOrEmpty(KECsmsAppKey))
                    KECsmsAppKey = ConfigurationManager.AppSettings["KECSmsAppKey"];
                return KECsmsAppKey;
            }
        }

        /// <summary>
        /// KEC阿里大于appSecret
        /// </summary>
        public static string KECSmsAppSecret
        {
            get
            {
                if (string.IsNullOrEmpty(KECsmsAppSecret))
                    KECsmsAppSecret = ConfigurationManager.AppSettings["KECSmsAppSecret"];
                return KECsmsAppSecret;
            }
        }

        /// <summary>
        /// KEC短信签名
        /// </summary>
        public static string KECSmsFreeSignName
        {
            get
            {
                if (string.IsNullOrEmpty(KECsmsFreeSignName))
                    KECsmsFreeSignName = ConfigurationManager.AppSettings["KECSmsFreeSignName"];
                return KECsmsFreeSignName;
            }
        }

        /// <summary>
        /// KEC金贝塔
        /// </summary>
        public static string KECSmsProductName
        {
            get
            {
                if (string.IsNullOrEmpty(KECsmsProductName))
                    KECsmsProductName = ConfigurationManager.AppSettings["KECSmsProductName"];
                return KECsmsProductName;
            }
        }

        /// <summary>
        /// KEC阿里大于URL
        /// </summary>
        public static string KECSmsUrl
        {
            get
            {
                if (string.IsNullOrEmpty(KECsmsUrl))
                    KECsmsUrl = ConfigurationManager.AppSettings["KECSmsUrl"];
                return KECsmsUrl;
            }
        }
        #endregion


        #region 及时聊天
        private static string rongCloudAppKey;
        private static string rongCloudAppSecret;

        /// <summary>
        /// 融云AppKey
        /// </summary>
        public static string RongCloudAppKey
        {
            get
            {
                if (string.IsNullOrEmpty(rongCloudAppKey))
                    rongCloudAppKey = ConfigurationManager.AppSettings["RongCloudAppKey"];
                return rongCloudAppKey;
            }
        }

        /// <summary>
        /// 融云AppSecret
        /// </summary>
        public static string RongCloudAppSecret
        {
            get
            {
                if (string.IsNullOrEmpty(rongCloudAppSecret))
                    rongCloudAppSecret = ConfigurationManager.AppSettings["RongCloudAppSecret"];
                return rongCloudAppSecret;
            }
        }

        #endregion

        #region 支付宝支付
        private static string alipayAppId;
        private static string alipayPartner;
        private static string alipayPrivateKeyPem;
        private static string alipaySellerId;
        private static string alipayNotifyUrl;
        private static string alipayPublicKey;
        /// <summary>
        /// AlipayAppId
        /// </summary>
        public static string AlipayAppId
        {
            get
            {
                if (string.IsNullOrEmpty(alipayAppId))
                    alipayAppId = ConfigurationManager.AppSettings["AlipayAppId"];
                return alipayAppId;
            }
        }
        /// <summary>
        /// AlipayPartner
        /// </summary>
        public static string AlipayPartner
        {
            get
            {
                if (string.IsNullOrEmpty(alipayPartner))
                    alipayPartner = ConfigurationManager.AppSettings["AlipayPartner"];
                return alipayPartner;
            }
        }
        /// <summary>
        /// 支付宝私钥
        /// </summary>
        public static string AlipayPrivateKeyPem
        {
            get
            {
                if (string.IsNullOrEmpty(alipayPrivateKeyPem))
                    alipayPrivateKeyPem = ConfigurationManager.AppSettings["AlipayPrivateKeyPem"];
                return alipayPrivateKeyPem;
            }
        }
        /// <summary>
        /// AlipaySellerId
        /// </summary>
        public static string AlipaySellerId
        {
            get
            {
                if (string.IsNullOrEmpty(alipaySellerId))
                    alipaySellerId = ConfigurationManager.AppSettings["AlipaySellerId"];
                return alipaySellerId;
            }
        }
        /// <summary>
        /// AlipayNotify
        /// </summary>
        public static string AlipayNotifyUrl
        {
            get
            {
                if (string.IsNullOrEmpty(alipayNotifyUrl))
                    alipayNotifyUrl = ConfigurationManager.AppSettings["AlipayNotifyUrl"];
                return alipayNotifyUrl;
            }
        }
        public static string AlipayPublicKey
        {
            get
            {
                if (string.IsNullOrEmpty(alipayPublicKey))
                    alipayPublicKey = ConfigurationManager.AppSettings["AlipayPublicKey"];
                return alipayPublicKey;
            }
        }

        #endregion

        #region 微信支付
        private static string weChatAppId;
        private static string weChatMchId;
        private static string weChatKey;
        private static string weChatAppSecret;
        private static string weChatNotifyUrl;
        /// <summary>
        /// WeChatAppId
        /// </summary>
        public static string WeChatAppId
        {
            get
            {
                if (string.IsNullOrEmpty(weChatAppId))
                    weChatAppId = ConfigurationManager.AppSettings["WeChatAppId"];
                return weChatAppId;
            }
        }
        /// <summary>
        /// WeChatMchId
        /// </summary>
        public static string WeChatMchId
        {
            get
            {
                if (string.IsNullOrEmpty(weChatMchId))
                    weChatMchId = ConfigurationManager.AppSettings["WeChatMchId"];
                return weChatMchId;
            }
        }
        /// <summary>
        /// WeChatKey
        /// </summary>
        public static string WeChatKey
        {
            get
            {
                if (string.IsNullOrEmpty(weChatKey))
                    weChatKey = ConfigurationManager.AppSettings["WeChatKey"];
                return weChatKey;
            }
        }
        /// <summary>
        /// WeChatAppSecret
        /// </summary>
        public static string WeChatAppSecret
        {
            get
            {
                if (string.IsNullOrEmpty(weChatAppSecret))
                    weChatAppSecret = ConfigurationManager.AppSettings["WeChatAppSecret"];
                return weChatAppSecret;
            }
        }
        /// <summary>
        /// 微信通知地址
        /// </summary>
        public static string WeChatNotifyUrl
        {
            get
            {
                if (string.IsNullOrEmpty(weChatNotifyUrl))
                    weChatNotifyUrl = ConfigurationManager.AppSettings["WeChatNotifyUrl"];
                return weChatNotifyUrl;
            }
        }
        #endregion

        #region App
        /// <summary>
        /// App是否可以支付
        /// </summary>
        private static int appIsPay = -1;
        /// <summary>
        /// 是否可以支付:0-不能支付，1-能支付
        /// </summary>
        public static int AppIsPay
        {
            get
            {
                if (appIsPay == -1)
                    appIsPay = Convert.ToInt32(ConfigurationManager.AppSettings["AppIsPay"]);
                return appIsPay;
            }
        }
        /// <summary>
        /// App是否可以提现
        /// </summary>
        private static int appIsWithdraw = -1;
        /// <summary>
        /// 是否可以提现:0-不可以提现，1-可以提现
        /// </summary>
        public static int AppIsWithdraw
        {
            get
            {
                if (appIsWithdraw == -1)
                    appIsWithdraw = Convert.ToInt32(ConfigurationManager.AppSettings["AppIsWithdraw"]);
                return appIsWithdraw;
            }
        }
        /// <summary>
        /// App是否可以提现---支付宝
        /// </summary>
        private static int appIsWithdrawAlipay = -1;
        /// <summary>
        /// 是否可以提现---支付宝:0-不可以提现，1-可以提现
        /// </summary>
        public static int AppIsWithdrawAlipay
        {
            get
            {
                if (appIsWithdrawAlipay == -1)
                    appIsWithdrawAlipay = Convert.ToInt32(ConfigurationManager.AppSettings["AppIsWithdrawAlipay"]);
                return appIsWithdrawAlipay;
            }
        }
        /// <summary>
        /// App是否可以元宝转注册币
        /// </summary>
        private static int appIsGoldConvertPoint = -1;
        /// <summary>
        /// 是否可以元宝转注册币:0-不可以提现，1-可以提现
        /// </summary>
        public static int AppIsGoldConvertPoint
        {
            get
            {
                if (appIsGoldConvertPoint == -1)
                    appIsGoldConvertPoint = Convert.ToInt32(ConfigurationManager.AppSettings["AppIsGoldConvertPoint"]);
                return appIsGoldConvertPoint;
            }
        }

        /// <summary>
        /// 是否可以元宝充值:0-不可以，1-可以
        /// </summary>
        private static int appIsGoldRecharge = -1;
        /// <summary>
        /// 是否可以元宝充值:0-不可以，1-可以
        /// </summary>
        public static int AppIsGoldRecharge
        {
            get
            {
                if (appIsGoldRecharge == -1)
                    appIsGoldRecharge = Convert.ToInt32(ConfigurationManager.AppSettings["AppIsGoldRecharge"]);
                return appIsGoldRecharge;
            }
        }
        /// <summary>
        /// 是否可以注册币充值:0-不可以，1-可以
        /// </summary>
        private static int appIsPointRecharge = -1;
        /// <summary>
        /// 是否可以注册币充值:0-不可以，1-可以
        /// </summary>
        public static int AppIsPointRecharge
        {
            get
            {
                if (appIsPointRecharge == -1)
                    appIsPointRecharge = Convert.ToInt32(ConfigurationManager.AppSettings["AppIsPointRecharge"]);
                return appIsPointRecharge;
            }
        }
        /// <summary>
        /// 是否bt1001投保测试:0-不测试，1-测试
        /// </summary>
        private static int insuranceIsTestUser = -1;
        /// <summary>
        /// 是否bt1001投保测试:0-不测试，1-测试
        /// </summary>
        public static int InsuranceIsTestUser
        {
            get
            {
                if (insuranceIsTestUser == -1)
                    insuranceIsTestUser = Convert.ToInt32(ConfigurationManager.AppSettings["InsuranceIsTestUser"]);
                return insuranceIsTestUser;
            }
        }

        /// <summary>
        /// 是否bt1001投保测试:0-不测试，1-测试
        /// </summary>
        private static int insuranceIsProfit = -1;
        /// <summary>
        /// 是否bt1001投保测试:0-不测试，1-测试
        /// </summary>
        public static int InsuranceIsProfit
        {
            get
            {
                if (insuranceIsProfit == -1)
                    insuranceIsProfit = Convert.ToInt32(ConfigurationManager.AppSettings["InsuranceIsProfit"]);
                return insuranceIsProfit;
            }
        }

        /// <summary>
        /// 万能验证码
        /// </summary>
        private static string everythingVerifyCode;
        /// <summary>
        /// 万能验证码
        /// </summary>
        public static string EverythingVerifyCode
        {
            get
            {
                if (string.IsNullOrEmpty(everythingVerifyCode))
                    everythingVerifyCode = ConfigurationManager.AppSettings["EverythingVerifyCode"].ToString();
                return everythingVerifyCode;
            }
        }

        /// <summary>
        /// 保险、提现非工作日
        /// </summary>
        private static string nonWorkingDays;
        /// <summary>
        /// 保险、提现非工作日
        /// </summary>
        public static string NonWorkingDays
        {
            get
            {
                if (string.IsNullOrEmpty(nonWorkingDays))
                    nonWorkingDays = ConfigurationManager.AppSettings["NonWorkingDays"].ToString();
                return nonWorkingDays;
            }
        }
        /// <summary>
        /// 保险、提现非工作日
        /// </summary>
        private static string startWorkingTime;
        /// <summary>
        /// 保险、提现非工作日
        /// </summary>
        public static string StartWorkingTime
        {
            get
            {
                if (string.IsNullOrEmpty(startWorkingTime))
                    startWorkingTime = ConfigurationManager.AppSettings["StartWorkingTime"].ToString();
                return startWorkingTime;
            }
        }
        /// <summary>
        /// 保险、提现非工作日
        /// </summary>
        private static string endWorkingTime;
        /// <summary>
        /// 保险、提现非工作日
        /// </summary>
        public static string EndWorkingTime
        {
            get
            {
                if (string.IsNullOrEmpty(endWorkingTime))
                    endWorkingTime = ConfigurationManager.AppSettings["EndWorkingTime"].ToString();
                return endWorkingTime;
            }
        }
        /// <summary>
        /// 保险、提现非工作日
        /// </summary>
        private static string holidays;
        /// <summary>
        /// 保险、提现非工作日
        /// </summary>
        public static string Holidays
        {
            get
            {
                if (string.IsNullOrEmpty(holidays))
                    holidays = ConfigurationManager.AppSettings["Holidays"].ToString();
                return holidays;
            }
        }
        #endregion

        private static List<string> appCloseFunction;

        public static List<string> AppCloseFunction
        {
            get
            {
                if (appCloseFunction == null)
                {
                    appCloseFunction = new List<string>();
                    try
                    {
                        string array = ConfigurationManager.AppSettings["AppCloseFunction"].ToString();
                        appCloseFunction.AddRange(array.Split(',').ToList());
                    }
                    catch (Exception ex)
                    {
                        LogHelper.WriteLog(ex);
                    }
                }

                return appCloseFunction;
            }
        }

        private static List<string> appFilterFunction;

        public static List<string> AppFilterFunction
        {
            get
            {
                if (appFilterFunction == null)
                {
                    appFilterFunction = new List<string>();
                    try
                    {
                        string array = ConfigurationManager.AppSettings["AppFilterFunction"].ToString();
                        appFilterFunction.AddRange(array.Split(',').ToList());
                    }
                    catch (Exception ex)
                    {
                        LogHelper.WriteLog(ex);
                    }
                }

                return appFilterFunction;
            }
        }

        private static List<string> webFilterFunction;

        public static List<string> WebFilterFunction
        {
            get
            {
                if (webFilterFunction == null)
                {
                    webFilterFunction = new List<string>();
                    try
                    {
                        string array = ConfigurationManager.AppSettings["WebFilterFunction"].ToString();
                        webFilterFunction.AddRange(array.Split(',').ToList());
                    }
                    catch (Exception ex)
                    {
                        LogHelper.WriteLog(ex);
                    }
                }

                return webFilterFunction;
            }
        }

        private static string _HostUrl;
        /// <summary>
        /// HostUrl
        /// </summary>
        public static string HostUrl
        {
            get
            {
                if (string.IsNullOrEmpty(_HostUrl))
                    _HostUrl = ConfigurationManager.AppSettings["HostUrl"];
                return _HostUrl;
            }
        }

        //微信支付
        public const string wx_appid = "wxd07eba69db86ecf8";
        public const string wx_mch_id = "1491392662";//e9a50655416be9f74024c6ed7176fe33
        public const string wx_api_key = "df6dd1f29fec47bfb980e9764730c37a";
        public const string wx_notify = "http://shop.betatime.net/api/payment/wxapipay/notify_url.aspx";


        /// <summary>
        /// 群组默认头像
        /// </summary>
        public const string GROUPLOGO = "http://beta.betatime.net/UploadFiles/img/group_logo.png";
        /// <summary>
        /// 用户默认头像
        /// </summary>
        public const string USERLOGO = "http://beta.betatime.net/UploadFiles/img/user_logo.png";

        /// <summary>
        /// 功能关闭提示系统
        /// </summary>
        public const string FunctionCloseMessage = "系统正在升级,该功能暂时无法使用。";

        /// <summary>
        /// 保证数量唯一修改
        /// </summary>
        public static Object CurrentAmount = new Object();
    }
}
